//package com.gamaker.app.widget;
//
//import android.app.Dialog;
//import android.content.Context;
//import android.support.annotation.StyleRes;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.widget.FrameLayout;
//
//import com.gamaker.app.R;
//import com.gamaker.app.ui.activity.BaseActivitySimple;
//import com.gamaker.app.util.SYSOUtils;
//
//import java.util.List;
//
//import io.reactivex.disposables.Disposable;
//
///**
// * 自定义Dialog
// */
//public class CiticDialog {
//
//    /**
//     * @param baseActivity
//     * @return LottieDialog
//     */
//    public CustomDialog createLottieDialog(BaseActivitySimple baseActivity) {
//        View view = LayoutInflater.from(baseActivity)
//                .inflate(R.layout.lottie_loading, null);
//
////        FrameLayout layout = (FrameLayout) view.findViewById(R.id.fl_loading);
//
//        initLottie(baseActivity, view);
//
////        CustomDialog dialog = new CustomDialog(baseActivity, R.style.Dialog);
////        dialog.setContentView(layout);
//        return dialog;
//    }
//
//    /**
//     * 初始哈Lottie动画
//     *
//     * @param context
//     * @param view
//     */
//    private void initLottie(Context context, View view) {
////        lottieLoading = (LottieAnimationView) view.findViewById(R.id.lottie_loading);
////        lottieLoading.setImageAssetsFolder("lottie_img");
////        LottieComposition.Factory
////                .fromAssetFileName(context, "loading.json", new OnCompositionLoadedListener() {
////                    @Override
////                    public void onCompositionLoaded(LottieComposition composition) {
////                        lottieLoading.setComposition(composition);
////                        lottieLoading.setSpeed(1.5f);
////                        lottieLoading.loop(true);
////                        lottieLoading.playAnimation();
////                    }
////                });
//    }
//
//    /**
//     * 自定义Dialog，传入BaseActivity，在onBackPressed->dismiss自动时dispose
//     */
//    public class CustomDialog extends Dialog {
//        private BaseActivitySimple baseActivity;
//        private boolean mCancelable;
//
//        CustomDialog(BaseActivitySimple baseActivity, @StyleRes int themeResId) {
//            super(baseActivity, themeResId);
//            this.baseActivity = baseActivity;
//        }
//
//        public void onDestroy() {
////            if (lottieLoading != null) {
////                lottieLoading.cancelAnimation();
////                lottieLoading.destroyDrawingCache();
////            }
//        }
//
//        @Override
//        protected void onStop() {
//            super.onStop();
//        }
//
//        @Override
//        public void dismiss() {
//            super.dismiss();
////            lottieLoading.pauseAnimation();
//        }
//
//        @Override
//        public void show() {
////            lottieLoading.resumeAnimation();
//            super.show();
//        }
//
//        @Override
//        public void setCancelable(boolean flag) {
//            super.setCancelable(flag);
//            mCancelable = flag;
//        }
//
//        /**
//         * 用户主动取消Dialog时终止RX
//         */
//        @Override
//        public void onBackPressed() {
//            if (mCancelable) {
//                cancel();
//                if (baseActivity != null) {
//                    SYSOUtils.sOut_("dispose!!!", baseActivity.disposableList.size());
//                    List<Disposable> disposableList = baseActivity.getDisposableList();
//                    for (Disposable d : disposableList) {
//                        if (d != null && !d.isDisposed()) {
//                            d.dispose();
//                        }
//                    }
//                    disposableList.clear();
//                }
//            }
//        }
//    }
//}